part of "../element.dart";

/// 与绘图Path、Paint有关的数值和预先写好的方法
class PATH {
  static Path bevelRectangle(
    double width,
    double height,
    CornerSize corner,
  ) {
    // 假设单边的宽为100
    final double halfX = width / 2;
    final double halfY = height / 2;

    final p = Path();

    // 由于flutter默认的y轴方向是反转的
    // 因此要得到现实中的

    // 右下
    p.moveTo(halfX, halfY - corner.bottomRight);
    p.lineTo(halfX - corner.bottomRight, halfY);
    // 左下
    p.lineTo(-(halfX - corner.bottomLeft), halfY);
    p.lineTo(-halfX, halfY - corner.bottomLeft);
    // 左上
    p.lineTo(-halfX, -(halfY - corner.topLeft));
    p.lineTo(-(halfX - corner.topLeft), -halfY);
    // 右上
    p.lineTo(halfX - corner.topRight, -halfY);
    p.lineTo(halfX, -(halfY - corner.topRight));
    // 闭合
    p.lineTo(halfX, halfY - corner.bottomRight);

    return p;
  }

  /// ×
  static Path get cross => parseSvgPathData(
        'M -50 -50 L 50 50 M 50 -50 L -50 50',
      );

  /// +
  static Path get add => parseSvgPathData(
        'M -50 0 L 50 0 M 0 -50 L 0 50',
      );

  /// ○
  static Path get circle => parseSvgPathData(
      "M 0 -60 C 30 -60 59 -35 59 0 C 59 30 30 57 0 57 C -29 56 -58 30 -58 0 C -58 -29 -35 -60 0 -60 Z");

  /// 打勾
  static Path get check => parseSvgPathData(
      "M -174 -11 Q -76 185 45 145 C 167 86 313 -459 552 -459");

  /// 秒表
  static Path get timer => parseSvgPathData(
      "M -0.036 -17.412 C -7.323 -17.547 -17.487 -11.023 -17.557 0.003 C -17.624 11.707 -7.529 17.407 -0.112 17.476 C 10.12 17.613 17.262 9.372 17.536 0.102 C 17.605 -9.032 9.639 -17.41 -0.027 -17.412 Z M -5.057 -26.887 H 4.901 M -0.044 -26.818 V -12.397 M -12.405 -11.995 L -8.915 -8.359 M -17.508 0.006 L -13.451 0.006 M -12.013 12.751 L -8.513 9.274 M -0.003 17.351 L -0.015 12.684 M 12.32 12.381 L 8.268 8.428 M 17.434 0.028 L 13.067 0.028 M 13.121 -11.162 L 9.423 -7.479 M -0.002 0.046 L -6.179 -5.87 M -0.002 0.046 H 7.074");

  /// 纸团、一团乱麻
  static Path get trash => parseSvgPathData(
      "M -115 -11 C -97 -24 -58 3 -60 -34 C -64 -60 -47 -89 -18 -80 C -8 -77 -5 -57 6 -41 C 23 -17 57 -2 82 -11 C 102 -22 105 -42 85 -59 C 65 -73 59 -29 28 -50 C 2 -67 -22 -43 -36 -10 C -52 29 -8 27 -9 53 C -10 74 -65 99 -92 80 C -108 67 -102 44 -76 38 C -38 30 -1 20 30 -6 C 43 -19 50 -48 42 -80 C 36 -97 23 -107 3 -105 C -18 -102 -35 -83 -34 -54 C -33 -26 -13 -12 6 -3 C 27 8 50 15 75 39 C 91 55 91 70 76 81 C 60 92 50 89 38 67 C 31 50 30 47 11 46");

  /// 返回 <~
  static Path get back => parseSvgPathData(
      "M 19.608 53.093 C 59.12 37.522 65.649 1.527 37.69 -19.903 C 19.943 -32.46 -4.501 -40.329 -50.542 -31.121 M -19.504 -58.549 C -29.27 -52.375 -37.801 -45.977 -46.669 -38.007 C -52.282 -32.955 -53.741 -29.027 -45.883 -26.22 C -35.781 -22.067 -28.484 -17.465 -17.371 -11.74");

  /// 无穷 ∞
  static Path get infinity => parseSvgPathData(
      "M 0 0 C -8.396 10.651 -19.569 27.576 -34.946 27.244 C -43.621 26.823 -61.832 24.003 -63.359 0.034 C -63.124 -15.475 -51.375 -28.634 -34.574 -26.989 C -21.414 -25.932 -12.015 -18.06 0.204 0.152 C 8.906 12.494 19.826 26.823 37.227 27.399 C 49.037 27.285 63.484 16.621 63.484 -0.004 C 62.223 -14.91 55.229 -25.918 37.227 -26.949 C 21.175 -26.605 10.855 -16.057 0 0 Z");

  /// 推迟 |->
  static Path get defer => parseSvgPathData(
      "M -43.499 -25.696 L -43.405 26.227 M -43.405 -0.018 L 52.983 0.171 M 29.004 -23.808 C 37.123 -14.84 43.354 -7.476 53.644 0.171 C 45.619 6.968 38.161 13.671 29.004 24.433");

  static Path get arrowLeft =>
      parseSvgPathData("M -50 0 L 50 0 M -7 -34 L -50 0 L -7 37");
  static Path get arrowUp =>
      parseSvgPathData("M -0 -50 L 0 50 M 34 -7 L -0 -50 L -37 -7");
  static Path get arrowDown =>
      parseSvgPathData("M 0 50 L -0 -50 M -34 7 L 0 50 L 37 7");
  static Path get arrowRight =>
      parseSvgPathData("M -50 0 L 50 0 M 7 -34 L 50 0 L 7 37");
}
